{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 103,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import pandas as pd\n",
    "\n",
    "import matplotlib.pyplot as plt\n",
    "import seaborn as sns\n",
    "\n",
    "from sklearn.metrics import r2_score\n",
    "\n",
    "%matplotlib inline\n",
    "\n",
    "train = pd.read_csv(\"Ames_House_train.csv\", skipinitialspace=True)\n",
    "train.head()\n",
    "\n",
    "#先去掉没用的数据\n",
    "train = train.drop('Id', axis = 1)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "metadata": {},
   "outputs": [],
   "source": [
    "train.shape\n",
    "train.tail(10)\n",
    "train = train[train[\"SalePrice\"] < 700000]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 104,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>MSSubClass</th>\n",
       "      <th>MSZoning</th>\n",
       "      <th>LotFrontage</th>\n",
       "      <th>LotArea</th>\n",
       "      <th>Street</th>\n",
       "      <th>Alley</th>\n",
       "      <th>LotShape</th>\n",
       "      <th>LandContour</th>\n",
       "      <th>Utilities</th>\n",
       "      <th>LotConfig</th>\n",
       "      <th>...</th>\n",
       "      <th>PoolArea</th>\n",
       "      <th>PoolQC</th>\n",
       "      <th>Fence</th>\n",
       "      <th>MiscFeature</th>\n",
       "      <th>MiscVal</th>\n",
       "      <th>MoSold</th>\n",
       "      <th>YrSold</th>\n",
       "      <th>SaleType</th>\n",
       "      <th>SaleCondition</th>\n",
       "      <th>SalePrice</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1450</th>\n",
       "      <td>90</td>\n",
       "      <td>RL</td>\n",
       "      <td>60.0</td>\n",
       "      <td>9000</td>\n",
       "      <td>Pave</td>\n",
       "      <td>nan1</td>\n",
       "      <td>Reg</td>\n",
       "      <td>Lvl</td>\n",
       "      <td>AllPub</td>\n",
       "      <td>FR2</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>nan1</td>\n",
       "      <td>nan1</td>\n",
       "      <td>nan1</td>\n",
       "      <td>0</td>\n",
       "      <td>9</td>\n",
       "      <td>2009</td>\n",
       "      <td>WD</td>\n",
       "      <td>Normal</td>\n",
       "      <td>136000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1451</th>\n",
       "      <td>20</td>\n",
       "      <td>RL</td>\n",
       "      <td>78.0</td>\n",
       "      <td>9262</td>\n",
       "      <td>Pave</td>\n",
       "      <td>nan1</td>\n",
       "      <td>Reg</td>\n",
       "      <td>Lvl</td>\n",
       "      <td>AllPub</td>\n",
       "      <td>Inside</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>nan1</td>\n",
       "      <td>nan1</td>\n",
       "      <td>nan1</td>\n",
       "      <td>0</td>\n",
       "      <td>5</td>\n",
       "      <td>2009</td>\n",
       "      <td>New</td>\n",
       "      <td>Partial</td>\n",
       "      <td>287090</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1452</th>\n",
       "      <td>180</td>\n",
       "      <td>RM</td>\n",
       "      <td>35.0</td>\n",
       "      <td>3675</td>\n",
       "      <td>Pave</td>\n",
       "      <td>nan1</td>\n",
       "      <td>Reg</td>\n",
       "      <td>Lvl</td>\n",
       "      <td>AllPub</td>\n",
       "      <td>Inside</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>nan1</td>\n",
       "      <td>nan1</td>\n",
       "      <td>nan1</td>\n",
       "      <td>0</td>\n",
       "      <td>5</td>\n",
       "      <td>2006</td>\n",
       "      <td>WD</td>\n",
       "      <td>Normal</td>\n",
       "      <td>145000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1453</th>\n",
       "      <td>20</td>\n",
       "      <td>RL</td>\n",
       "      <td>90.0</td>\n",
       "      <td>17217</td>\n",
       "      <td>Pave</td>\n",
       "      <td>nan1</td>\n",
       "      <td>Reg</td>\n",
       "      <td>Lvl</td>\n",
       "      <td>AllPub</td>\n",
       "      <td>Inside</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>nan1</td>\n",
       "      <td>nan1</td>\n",
       "      <td>nan1</td>\n",
       "      <td>0</td>\n",
       "      <td>7</td>\n",
       "      <td>2006</td>\n",
       "      <td>WD</td>\n",
       "      <td>Abnorml</td>\n",
       "      <td>84500</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1454</th>\n",
       "      <td>20</td>\n",
       "      <td>FV</td>\n",
       "      <td>62.0</td>\n",
       "      <td>7500</td>\n",
       "      <td>Pave</td>\n",
       "      <td>Pave</td>\n",
       "      <td>Reg</td>\n",
       "      <td>Lvl</td>\n",
       "      <td>AllPub</td>\n",
       "      <td>Inside</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>nan1</td>\n",
       "      <td>nan1</td>\n",
       "      <td>nan1</td>\n",
       "      <td>0</td>\n",
       "      <td>10</td>\n",
       "      <td>2009</td>\n",
       "      <td>WD</td>\n",
       "      <td>Normal</td>\n",
       "      <td>185000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1455</th>\n",
       "      <td>60</td>\n",
       "      <td>RL</td>\n",
       "      <td>62.0</td>\n",
       "      <td>7917</td>\n",
       "      <td>Pave</td>\n",
       "      <td>nan1</td>\n",
       "      <td>Reg</td>\n",
       "      <td>Lvl</td>\n",
       "      <td>AllPub</td>\n",
       "      <td>Inside</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>nan1</td>\n",
       "      <td>nan1</td>\n",
       "      <td>nan1</td>\n",
       "      <td>0</td>\n",
       "      <td>8</td>\n",
       "      <td>2007</td>\n",
       "      <td>WD</td>\n",
       "      <td>Normal</td>\n",
       "      <td>175000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1456</th>\n",
       "      <td>20</td>\n",
       "      <td>RL</td>\n",
       "      <td>85.0</td>\n",
       "      <td>13175</td>\n",
       "      <td>Pave</td>\n",
       "      <td>nan1</td>\n",
       "      <td>Reg</td>\n",
       "      <td>Lvl</td>\n",
       "      <td>AllPub</td>\n",
       "      <td>Inside</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>nan1</td>\n",
       "      <td>MnPrv</td>\n",
       "      <td>nan1</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>2010</td>\n",
       "      <td>WD</td>\n",
       "      <td>Normal</td>\n",
       "      <td>210000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1457</th>\n",
       "      <td>70</td>\n",
       "      <td>RL</td>\n",
       "      <td>66.0</td>\n",
       "      <td>9042</td>\n",
       "      <td>Pave</td>\n",
       "      <td>nan1</td>\n",
       "      <td>Reg</td>\n",
       "      <td>Lvl</td>\n",
       "      <td>AllPub</td>\n",
       "      <td>Inside</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>nan1</td>\n",
       "      <td>GdPrv</td>\n",
       "      <td>Shed</td>\n",
       "      <td>2500</td>\n",
       "      <td>5</td>\n",
       "      <td>2010</td>\n",
       "      <td>WD</td>\n",
       "      <td>Normal</td>\n",
       "      <td>266500</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1458</th>\n",
       "      <td>20</td>\n",
       "      <td>RL</td>\n",
       "      <td>68.0</td>\n",
       "      <td>9717</td>\n",
       "      <td>Pave</td>\n",
       "      <td>nan1</td>\n",
       "      <td>Reg</td>\n",
       "      <td>Lvl</td>\n",
       "      <td>AllPub</td>\n",
       "      <td>Inside</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>nan1</td>\n",
       "      <td>nan1</td>\n",
       "      <td>nan1</td>\n",
       "      <td>0</td>\n",
       "      <td>4</td>\n",
       "      <td>2010</td>\n",
       "      <td>WD</td>\n",
       "      <td>Normal</td>\n",
       "      <td>142125</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1459</th>\n",
       "      <td>20</td>\n",
       "      <td>RL</td>\n",
       "      <td>75.0</td>\n",
       "      <td>9937</td>\n",
       "      <td>Pave</td>\n",
       "      <td>nan1</td>\n",
       "      <td>Reg</td>\n",
       "      <td>Lvl</td>\n",
       "      <td>AllPub</td>\n",
       "      <td>Inside</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>nan1</td>\n",
       "      <td>nan1</td>\n",
       "      <td>nan1</td>\n",
       "      <td>0</td>\n",
       "      <td>6</td>\n",
       "      <td>2008</td>\n",
       "      <td>WD</td>\n",
       "      <td>Normal</td>\n",
       "      <td>147500</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>10 rows × 80 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "      MSSubClass MSZoning  LotFrontage  LotArea Street Alley LotShape  \\\n",
       "1450          90       RL         60.0     9000   Pave  nan1      Reg   \n",
       "1451          20       RL         78.0     9262   Pave  nan1      Reg   \n",
       "1452         180       RM         35.0     3675   Pave  nan1      Reg   \n",
       "1453          20       RL         90.0    17217   Pave  nan1      Reg   \n",
       "1454          20       FV         62.0     7500   Pave  Pave      Reg   \n",
       "1455          60       RL         62.0     7917   Pave  nan1      Reg   \n",
       "1456          20       RL         85.0    13175   Pave  nan1      Reg   \n",
       "1457          70       RL         66.0     9042   Pave  nan1      Reg   \n",
       "1458          20       RL         68.0     9717   Pave  nan1      Reg   \n",
       "1459          20       RL         75.0     9937   Pave  nan1      Reg   \n",
       "\n",
       "     LandContour Utilities LotConfig    ...     PoolArea PoolQC  Fence  \\\n",
       "1450         Lvl    AllPub       FR2    ...            0   nan1   nan1   \n",
       "1451         Lvl    AllPub    Inside    ...            0   nan1   nan1   \n",
       "1452         Lvl    AllPub    Inside    ...            0   nan1   nan1   \n",
       "1453         Lvl    AllPub    Inside    ...            0   nan1   nan1   \n",
       "1454         Lvl    AllPub    Inside    ...            0   nan1   nan1   \n",
       "1455         Lvl    AllPub    Inside    ...            0   nan1   nan1   \n",
       "1456         Lvl    AllPub    Inside    ...            0   nan1  MnPrv   \n",
       "1457         Lvl    AllPub    Inside    ...            0   nan1  GdPrv   \n",
       "1458         Lvl    AllPub    Inside    ...            0   nan1   nan1   \n",
       "1459         Lvl    AllPub    Inside    ...            0   nan1   nan1   \n",
       "\n",
       "     MiscFeature MiscVal MoSold  YrSold  SaleType  SaleCondition  SalePrice  \n",
       "1450        nan1       0      9    2009        WD         Normal     136000  \n",
       "1451        nan1       0      5    2009       New        Partial     287090  \n",
       "1452        nan1       0      5    2006        WD         Normal     145000  \n",
       "1453        nan1       0      7    2006        WD        Abnorml      84500  \n",
       "1454        nan1       0     10    2009        WD         Normal     185000  \n",
       "1455        nan1       0      8    2007        WD         Normal     175000  \n",
       "1456        nan1       0      2    2010        WD         Normal     210000  \n",
       "1457        Shed    2500      5    2010        WD         Normal     266500  \n",
       "1458        nan1       0      4    2010        WD         Normal     142125  \n",
       "1459        nan1       0      6    2008        WD         Normal     147500  \n",
       "\n",
       "[10 rows x 80 columns]"
      ]
     },
     "execution_count": 104,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "type(train.iat[1450, 5])\n",
    "#这里把 nan 替换为 nan1 字符串,方便后面统计 每个特征的 均价\n",
    "#可能按每列中出现次数最多的 来填补 确实 可能效果更好？\n",
    "for col in cols:\n",
    "    train2 = train.copy()\n",
    "    if train[col].dtype == object:\n",
    "        train[col] = train[col].where(train[col].notnull(), \"nan1\")\n",
    "train.tail(10)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 105,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "'''\n",
    "经过直接去掉object类型的数据，发现 对 最终的结果影响非常大，证明  在object中 有 特征 对SalePrice的贡献很大\n",
    "接下来 思路是  根据  每个特征对应的SalePrice的均值 对 每个特征进行 排序， 用最后的排序结果的下标 代替 object类型\n",
    "也就是 默认 每种object特征 都对 价格有影响，且和价格是线性关系，这样做的好处是 方便处理，拟合会更简单\n",
    "可能带来问题是  人为的 制造了线性关系，可能带来过拟合的问题\n",
    "'''\n",
    "train2 = train.copy()\n",
    "cols = train.columns\n",
    "colindex = 0\n",
    "for col in cols:\n",
    "    train2 = train.copy()\n",
    "    if type(train2.loc[0,col]) == str: #train[col].dtype == object\n",
    "        ex_list = set(train2[col])\n",
    "        dic = {}\n",
    "        #下面这段代码 是 给 每个特征 下的 每个值 计算均价\n",
    "        for value in ex_list:               \n",
    "            arr = train2[train2[col] == value]['SalePrice']\n",
    "            dic[value] = arr.sum() / len(arr)\n",
    "            train2 = train2[train2[col] != value]\n",
    "        #接下来排序\n",
    "        #rank = {}\n",
    "        for a in dic:\n",
    "            cnt = 1\n",
    "            for b in dic:\n",
    "                if dic[b] < dic[a]:\n",
    "                    cnt += 1\n",
    "            rank[a] = cnt\n",
    "        #print(rank)\n",
    "        #接下来做替换\n",
    "        for i in range(0, len(train)):\n",
    "            value = train.iat[i, colindex]\n",
    "            train.iat[i, colindex] = rank[value]\n",
    "            \n",
    "    colindex += 1 \n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 106,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>MSSubClass</th>\n",
       "      <th>MSZoning</th>\n",
       "      <th>LotFrontage</th>\n",
       "      <th>LotArea</th>\n",
       "      <th>Street</th>\n",
       "      <th>Alley</th>\n",
       "      <th>LotShape</th>\n",
       "      <th>LandContour</th>\n",
       "      <th>Utilities</th>\n",
       "      <th>LotConfig</th>\n",
       "      <th>...</th>\n",
       "      <th>PoolArea</th>\n",
       "      <th>PoolQC</th>\n",
       "      <th>Fence</th>\n",
       "      <th>MiscFeature</th>\n",
       "      <th>MiscVal</th>\n",
       "      <th>MoSold</th>\n",
       "      <th>YrSold</th>\n",
       "      <th>SaleType</th>\n",
       "      <th>SaleCondition</th>\n",
       "      <th>SalePrice</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1455</th>\n",
       "      <td>60</td>\n",
       "      <td>4</td>\n",
       "      <td>62.0</td>\n",
       "      <td>7917</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>5</td>\n",
       "      <td>4</td>\n",
       "      <td>0</td>\n",
       "      <td>8</td>\n",
       "      <td>2007</td>\n",
       "      <td>5</td>\n",
       "      <td>5</td>\n",
       "      <td>175000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1456</th>\n",
       "      <td>20</td>\n",
       "      <td>4</td>\n",
       "      <td>85.0</td>\n",
       "      <td>13175</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>3</td>\n",
       "      <td>4</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>2010</td>\n",
       "      <td>5</td>\n",
       "      <td>5</td>\n",
       "      <td>210000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1457</th>\n",
       "      <td>70</td>\n",
       "      <td>4</td>\n",
       "      <td>66.0</td>\n",
       "      <td>9042</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>4</td>\n",
       "      <td>2</td>\n",
       "      <td>2500</td>\n",
       "      <td>5</td>\n",
       "      <td>2010</td>\n",
       "      <td>5</td>\n",
       "      <td>5</td>\n",
       "      <td>266500</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1458</th>\n",
       "      <td>20</td>\n",
       "      <td>4</td>\n",
       "      <td>68.0</td>\n",
       "      <td>9717</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>5</td>\n",
       "      <td>4</td>\n",
       "      <td>0</td>\n",
       "      <td>4</td>\n",
       "      <td>2010</td>\n",
       "      <td>5</td>\n",
       "      <td>5</td>\n",
       "      <td>142125</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1459</th>\n",
       "      <td>20</td>\n",
       "      <td>4</td>\n",
       "      <td>75.0</td>\n",
       "      <td>9937</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>5</td>\n",
       "      <td>4</td>\n",
       "      <td>0</td>\n",
       "      <td>6</td>\n",
       "      <td>2008</td>\n",
       "      <td>5</td>\n",
       "      <td>5</td>\n",
       "      <td>147500</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 80 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "      MSSubClass MSZoning  LotFrontage  LotArea Street Alley LotShape  \\\n",
       "1455          60        4         62.0     7917      2     3        1   \n",
       "1456          20        4         85.0    13175      2     3        1   \n",
       "1457          70        4         66.0     9042      2     3        1   \n",
       "1458          20        4         68.0     9717      2     3        1   \n",
       "1459          20        4         75.0     9937      2     3        1   \n",
       "\n",
       "     LandContour Utilities LotConfig    ...     PoolArea PoolQC Fence  \\\n",
       "1455           2         2         1    ...            0      1     5   \n",
       "1456           2         2         1    ...            0      1     3   \n",
       "1457           2         2         1    ...            0      1     4   \n",
       "1458           2         2         1    ...            0      1     5   \n",
       "1459           2         2         1    ...            0      1     5   \n",
       "\n",
       "     MiscFeature MiscVal MoSold  YrSold  SaleType  SaleCondition  SalePrice  \n",
       "1455           4       0      8    2007         5              5     175000  \n",
       "1456           4       0      2    2010         5              5     210000  \n",
       "1457           2    2500      5    2010         5              5     266500  \n",
       "1458           4       0      4    2010         5              5     142125  \n",
       "1459           4       0      6    2008         5              5     147500  \n",
       "\n",
       "[5 rows x 80 columns]"
      ]
     },
     "execution_count": 106,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from sklearn.preprocessing import Imputer\n",
    "imp = Imputer(missing_values=np.nan, strategy='most_frequent', axis=0)\n",
    "imp.fit(train)\n",
    "train.tail()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 107,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAZYAAAENCAYAAAAsWUMWAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYi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Bj+Od7uzBO5Ia/2X/MbzrTVvxLmZ/xm2TaP+D96PhH/BmL7wQiNUzKlWf07hUdRvw58D/w/ssvw94X9j7cjJ17cU7uv47oAPvCOZv8b5XfXifh/14r/1yvGs9ecHmYzHGnBYi8j28qYe/mO5YzOSyIxZjjDEpZYnFGGNMStmpMGOMMSllRyzGGGNSyhKLMcaYlLLEYowxJqUssRhjjEkpSyzGGGNSyhKLMcaYlPr/Yu/BjfumtJAAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x7fa18ad26f28>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "\"\\n\\n#接下来 查看特征之间的相关性，去掉一部分冗余特征\\ndata_corr = train.corr().abs()\\nplt.subplots(figsize=(13, 9))\\nsns.heatmap(data_corr,annot=True)\\n\\n# Mask unimportant features\\nsns.heatmap(data_corr, mask=data_corr < 1, cbar=False)\\n\\nplt.savefig('data.png' )\\nplt.show()\""
      ]
     },
     "execution_count": 107,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#pd.isnull(train) 经过运行 没有空的值了，开始下一步\n",
    "# 目标y（房屋价格）的直方图／分布\n",
    "fig = plt.figure()\n",
    "sns.distplot(train.SalePrice.values, bins=30, kde=True)\n",
    "plt.xlabel('Median value of owner-occupied homes', fontsize=12)\n",
    "plt.show()\n",
    "'''\n",
    "\n",
    "#接下来 查看特征之间的相关性，去掉一部分冗余特征\n",
    "data_corr = train.corr().abs()\n",
    "plt.subplots(figsize=(13, 9))\n",
    "sns.heatmap(data_corr,annot=True)\n",
    "\n",
    "# Mask unimportant features\n",
    "sns.heatmap(data_corr, mask=data_corr < 1, cbar=False)\n",
    "\n",
    "plt.savefig('data.png' )\n",
    "plt.show()'''"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 108,
   "metadata": {},
   "outputs": [],
   "source": [
    "#切割 X 和 y\n",
    "X = train.drop('SalePrice', axis = 1)\n",
    "y = train['SalePrice']\n",
    "\n",
    "cols = X.columns\n",
    "\n",
    "\n",
    "from sklearn.preprocessing import Imputer  \n",
    "imp = Imputer(missing_values='NaN' , strategy='mean', axis=0)  \n",
    "X = imp.fit_transform(X)  \n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 109,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(1168, 79)"
      ]
     },
     "execution_count": 109,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from sklearn.model_selection import train_test_split\n",
    "\n",
    "# 随机采样20%的数据构建测试样本，其余作为训练样本\n",
    "X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=33, test_size=0.2)\n",
    "X_train.shape\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 110,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/home/lyp/.local/lib/python3.6/site-packages/ipykernel_launcher.py:27: FutureWarning: reshape is deprecated and will raise in a subsequent release. Please use .values.reshape(...) instead\n",
      "/home/lyp/.local/lib/python3.6/site-packages/sklearn/utils/validation.py:475: DataConversionWarning: Data with input dtype int64 was converted to float64 by StandardScaler.\n",
      "  warnings.warn(msg, DataConversionWarning)\n",
      "/home/lyp/.local/lib/python3.6/site-packages/ipykernel_launcher.py:28: FutureWarning: reshape is deprecated and will raise in a subsequent release. Please use .values.reshape(...) instead\n"
     ]
    }
   ],
   "source": [
    "#下来数据归一化\n",
    "'''\n",
    "from sklearn.preprocessing import MinMaxScaler\n",
    "\n",
    "ms_X = MinMaxScaler()\n",
    "ms_y = MinMaxScaler()\n",
    "\n",
    "X_train = ms_X.fit_transform(X_train)\n",
    "X_test = ms_X.fit_transform(X_test)\n",
    "\n",
    "\n",
    "#y_train = ms_y.fit_transform(y_train.reshape(-1, 1))\n",
    "#y_test = ms_y.transform(y_test.reshape(-1, 1))\n",
    "'''\n",
    "from sklearn.preprocessing import StandardScaler\n",
    "\n",
    "# 分别初始化对特征和目标值的标准化器\n",
    "ss_X = StandardScaler()\n",
    "ss_y = StandardScaler()\n",
    "\n",
    "\n",
    "# 分别对训练和测试数据的特征以及目标值进行标准化处理\n",
    "X_train = ss_X.fit_transform(X_train)\n",
    "X_test = ss_X.transform(X_test)\n",
    "\n",
    "#对y标准化的好处是不同问题的w差异不太大，同时正则参数的范围也有限\n",
    "y_train = ss_y.fit_transform(y_train.reshape(-1, 1))\n",
    "y_test = ss_y.transform(y_test.reshape(-1, 1))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 111,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>coef</th>\n",
       "      <th>columns</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>37</th>\n",
       "      <td>[697203090.0442257]</td>\n",
       "      <td>TotalBsmtSF</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>43</th>\n",
       "      <td>[376833259.0414039]</td>\n",
       "      <td>2ndFlrSF</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>42</th>\n",
       "      <td>[323460514.3564978]</td>\n",
       "      <td>1stFlrSF</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>44</th>\n",
       "      <td>[42557472.6615598]</td>\n",
       "      <td>LowQualFinSF</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>[0.15190566183826018]</td>\n",
       "      <td>OverallQual</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>[0.1336450494052555]</td>\n",
       "      <td>Neighborhood</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>53</th>\n",
       "      <td>[0.08317462765298878]</td>\n",
       "      <td>TotRmsAbvGrd</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>[0.0812489308004839]</td>\n",
       "      <td>OverallCond</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>52</th>\n",
       "      <td>[0.07789835379085368]</td>\n",
       "      <td>KitchenQual</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>77</th>\n",
       "      <td>[0.06776793739093982]</td>\n",
       "      <td>SaleType</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>31</th>\n",
       "      <td>[0.06618859283592715]</td>\n",
       "      <td>BsmtExposure</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>71</th>\n",
       "      <td>[0.06304260643113531]</td>\n",
       "      <td>PoolQC</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26</th>\n",
       "      <td>[0.060419752263565794]</td>\n",
       "      <td>ExterQual</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>[0.053648105171333615]</td>\n",
       "      <td>YearBuilt</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25</th>\n",
       "      <td>[0.05211244992309751]</td>\n",
       "      <td>MasVnrArea</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21</th>\n",
       "      <td>[0.05010077487474757]</td>\n",
       "      <td>RoofMatl</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>29</th>\n",
       "      <td>[0.0499407521550492]</td>\n",
       "      <td>BsmtQual</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>60</th>\n",
       "      <td>[0.044032401692656375]</td>\n",
       "      <td>GarageCars</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>[0.04031466265403149]</td>\n",
       "      <td>LotArea</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>54</th>\n",
       "      <td>[0.037302402073657176]</td>\n",
       "      <td>Functional</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>78</th>\n",
       "      <td>[0.03162465620001029]</td>\n",
       "      <td>SaleCondition</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>61</th>\n",
       "      <td>[0.028453565633348367]</td>\n",
       "      <td>GarageArea</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>65</th>\n",
       "      <td>[0.026662235707970886]</td>\n",
       "      <td>WoodDeckSF</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>39</th>\n",
       "      <td>[0.024911136884728825]</td>\n",
       "      <td>HeatingQC</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>[0.02397438844750646]</td>\n",
       "      <td>Street</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20</th>\n",
       "      <td>[0.023785971632157163]</td>\n",
       "      <td>RoofStyle</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>69</th>\n",
       "      <td>[0.023095265378144485]</td>\n",
       "      <td>ScreenPorch</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>55</th>\n",
       "      <td>[0.02144549033968042]</td>\n",
       "      <td>Fireplaces</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>[0.021354509007919215]</td>\n",
       "      <td>Utilities</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>[0.020935334230237506]</td>\n",
       "      <td>Condition1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>72</th>\n",
       "      <td>[-0.002871163937536114]</td>\n",
       "      <td>Fence</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27</th>\n",
       "      <td>[-0.003866524943106093]</td>\n",
       "      <td>ExterCond</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24</th>\n",
       "      <td>[-0.005462122665317259]</td>\n",
       "      <td>MasVnrType</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>58</th>\n",
       "      <td>[-0.006195818394321373]</td>\n",
       "      <td>GarageYrBlt</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>40</th>\n",
       "      <td>[-0.006581846026080057]</td>\n",
       "      <td>CentralAir</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>47</th>\n",
       "      <td>[-0.006641507150942444]</td>\n",
       "      <td>BsmtHalfBath</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>70</th>\n",
       "      <td>[-0.008694623430595037]</td>\n",
       "      <td>PoolArea</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>32</th>\n",
       "      <td>[-0.01100438883739932]</td>\n",
       "      <td>BsmtFinType1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>[-0.011839558571810828]</td>\n",
       "      <td>HouseStyle</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>64</th>\n",
       "      <td>[-0.012495497396422459]</td>\n",
       "      <td>PavedDrive</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>34</th>\n",
       "      <td>[-0.013407328532184112]</td>\n",
       "      <td>BsmtFinType2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>73</th>\n",
       "      <td>[-0.014332464595932645]</td>\n",
       "      <td>MiscFeature</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>[-0.014735023016824627]</td>\n",
       "      <td>MSZoning</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>74</th>\n",
       "      <td>[-0.015348429300937091]</td>\n",
       "      <td>MiscVal</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>75</th>\n",
       "      <td>[-0.019469954198842933]</td>\n",
       "      <td>MoSold</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>[-0.020178566292776923]</td>\n",
       "      <td>LandSlope</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>[-0.020249081814640715]</td>\n",
       "      <td>YearRemodAdd</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>41</th>\n",
       "      <td>[-0.02182629422456501]</td>\n",
       "      <td>Electrical</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>57</th>\n",
       "      <td>[-0.03368224087182968]</td>\n",
       "      <td>GarageType</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>30</th>\n",
       "      <td>[-0.03595504870297171]</td>\n",
       "      <td>BsmtCond</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>63</th>\n",
       "      <td>[-0.04350648018988962]</td>\n",
       "      <td>GarageCond</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>[-0.048452265973427326]</td>\n",
       "      <td>BldgType</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>[-0.05166540561995758]</td>\n",
       "      <td>Condition2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>50</th>\n",
       "      <td>[-0.05827938513278778]</td>\n",
       "      <td>BedroomAbvGr</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>51</th>\n",
       "      <td>[-0.0716693079971073]</td>\n",
       "      <td>KitchenAbvGr</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>[-0.09209047114582049]</td>\n",
       "      <td>MSSubClass</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>35</th>\n",
       "      <td>[-250553554.48081526]</td>\n",
       "      <td>BsmtFinSF2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>45</th>\n",
       "      <td>[-442660173.95732915]</td>\n",
       "      <td>GrLivArea</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>33</th>\n",
       "      <td>[-713137974.4239174]</td>\n",
       "      <td>BsmtFinSF1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>36</th>\n",
       "      <td>[-723116065.5138352]</td>\n",
       "      <td>BsmtUnfSF</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>79 rows × 2 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                       coef        columns\n",
       "37      [697203090.0442257]    TotalBsmtSF\n",
       "43      [376833259.0414039]       2ndFlrSF\n",
       "42      [323460514.3564978]       1stFlrSF\n",
       "44       [42557472.6615598]   LowQualFinSF\n",
       "16    [0.15190566183826018]    OverallQual\n",
       "11     [0.1336450494052555]   Neighborhood\n",
       "53    [0.08317462765298878]   TotRmsAbvGrd\n",
       "17     [0.0812489308004839]    OverallCond\n",
       "52    [0.07789835379085368]    KitchenQual\n",
       "77    [0.06776793739093982]       SaleType\n",
       "31    [0.06618859283592715]   BsmtExposure\n",
       "71    [0.06304260643113531]         PoolQC\n",
       "26   [0.060419752263565794]      ExterQual\n",
       "18   [0.053648105171333615]      YearBuilt\n",
       "25    [0.05211244992309751]     MasVnrArea\n",
       "21    [0.05010077487474757]       RoofMatl\n",
       "29     [0.0499407521550492]       BsmtQual\n",
       "60   [0.044032401692656375]     GarageCars\n",
       "3     [0.04031466265403149]        LotArea\n",
       "54   [0.037302402073657176]     Functional\n",
       "78    [0.03162465620001029]  SaleCondition\n",
       "61   [0.028453565633348367]     GarageArea\n",
       "65   [0.026662235707970886]     WoodDeckSF\n",
       "39   [0.024911136884728825]      HeatingQC\n",
       "4     [0.02397438844750646]         Street\n",
       "20   [0.023785971632157163]      RoofStyle\n",
       "69   [0.023095265378144485]    ScreenPorch\n",
       "55    [0.02144549033968042]     Fireplaces\n",
       "8    [0.021354509007919215]      Utilities\n",
       "12   [0.020935334230237506]     Condition1\n",
       "..                      ...            ...\n",
       "72  [-0.002871163937536114]          Fence\n",
       "27  [-0.003866524943106093]      ExterCond\n",
       "24  [-0.005462122665317259]     MasVnrType\n",
       "58  [-0.006195818394321373]    GarageYrBlt\n",
       "40  [-0.006581846026080057]     CentralAir\n",
       "47  [-0.006641507150942444]   BsmtHalfBath\n",
       "70  [-0.008694623430595037]       PoolArea\n",
       "32   [-0.01100438883739932]   BsmtFinType1\n",
       "15  [-0.011839558571810828]     HouseStyle\n",
       "64  [-0.012495497396422459]     PavedDrive\n",
       "34  [-0.013407328532184112]   BsmtFinType2\n",
       "73  [-0.014332464595932645]    MiscFeature\n",
       "1   [-0.014735023016824627]       MSZoning\n",
       "74  [-0.015348429300937091]        MiscVal\n",
       "75  [-0.019469954198842933]         MoSold\n",
       "10  [-0.020178566292776923]      LandSlope\n",
       "19  [-0.020249081814640715]   YearRemodAdd\n",
       "41   [-0.02182629422456501]     Electrical\n",
       "57   [-0.03368224087182968]     GarageType\n",
       "30   [-0.03595504870297171]       BsmtCond\n",
       "63   [-0.04350648018988962]     GarageCond\n",
       "14  [-0.048452265973427326]       BldgType\n",
       "13   [-0.05166540561995758]     Condition2\n",
       "50   [-0.05827938513278778]   BedroomAbvGr\n",
       "51    [-0.0716693079971073]   KitchenAbvGr\n",
       "0    [-0.09209047114582049]     MSSubClass\n",
       "35    [-250553554.48081526]     BsmtFinSF2\n",
       "45    [-442660173.95732915]      GrLivArea\n",
       "33     [-713137974.4239174]     BsmtFinSF1\n",
       "36     [-723116065.5138352]      BsmtUnfSF\n",
       "\n",
       "[79 rows x 2 columns]"
      ]
     },
     "execution_count": 111,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 线性回归\n",
    "#class sklearn.linear_model.LinearRegression(fit_intercept=True, normalize=False, copy_X=True, n_jobs=1)\n",
    "from sklearn.linear_model import LinearRegression\n",
    "\n",
    "# 使用默认配置初始化\n",
    "lr = LinearRegression()\n",
    "\n",
    "# 训练模型参数\n",
    "lr.fit(X_train, y_train)\n",
    "\n",
    "# 预测\n",
    "y_test_pred_lr = lr.predict(X_test)\n",
    "y_train_pred_lr = lr.predict(X_train)\n",
    "\n",
    "\n",
    "# 看看各特征的权重系数，系数的绝对值大小可视为该特征的重要性\n",
    "fs = pd.DataFrame({\"columns\":list(cols), \"coef\":list((lr.coef_.T))})\n",
    "fs.sort_values(by=['coef'],ascending=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 112,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The r2 score of LinearRegression on test is 0.7088337344744944\n",
      "The r2 score of LinearRegression on train is 0.8754621999271018\n"
     ]
    }
   ],
   "source": [
    "# 使用r2_score评价模型在测试集和训练集上的性能，并输出评估结果\n",
    "#测试集\n",
    "print( 'The r2 score of LinearRegression on test is', r2_score(y_test, y_test_pred_lr))\n",
    "#训练集\n",
    "print('The r2 score of LinearRegression on train is', r2_score(y_train, y_train_pred_lr))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 113,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The r2 score of LassoCV on test is 0.7277368531399511\n",
      "The r2 score of LassoCV on train is 0.8693285165795839\n",
      "alpha is: 0.010235310218990263\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/home/lyp/.local/lib/python3.6/site-packages/sklearn/linear_model/coordinate_descent.py:1094: DataConversionWarning: A column-vector y was passed when a 1d array was expected. Please change the shape of y to (n_samples, ), for example using ravel().\n",
      "  y = column_or_1d(y, warn=True)\n"
     ]
    }
   ],
   "source": [
    "#### Lasso／L1正则\n",
    "# class sklearn.linear_model.LassoCV(eps=0.001, n_alphas=100, alphas=None, fit_intercept=True, \n",
    "#                                    normalize=False, precompute=’auto’, max_iter=1000, \n",
    "#                                    tol=0.0001, copy_X=True, cv=None, verbose=False, n_jobs=1,\n",
    "#                                    positive=False, random_state=None, selection=’cyclic’)\n",
    "from sklearn.linear_model import LassoCV\n",
    "\n",
    "#设置超参数搜索范围\n",
    "alphas = [ 0.01, 0.011, 0.012]\n",
    "\n",
    "# alphas count is 200, 都在10的-3次方和2的3次方之间\n",
    "n_alphas = 100\n",
    "alphas = np.logspace(-3, 2, n_alphas)\n",
    "\n",
    "\n",
    "#生成一个LassoCV实例\n",
    "lasso = LassoCV(alphas=alphas)   \n",
    "\n",
    "#训练（内含CV）\n",
    "lasso.fit(X_train, y_train)  \n",
    "\n",
    "#测试\n",
    "y_test_pred_lasso = lasso.predict(X_test)\n",
    "y_train_pred_lasso = lasso.predict(X_train)\n",
    "\n",
    "\n",
    "# 评估，使用r2_score评价模型在测试集和训练集上的性能\n",
    "print( 'The r2 score of LassoCV on test is', r2_score(y_test, y_test_pred_lasso))\n",
    "print( 'The r2 score of LassoCV on train is', r2_score(y_train, y_train_pred_lasso))\n",
    "\n",
    "print ('alpha is:', lasso.alpha_)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 114,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAe8AAAFsCAYAAADlrTG7AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvNQv5yAAAHexJREFUeJzt3XuUXWWZ5/HvY1IQm0CQXDAkaAKCCgSSTBGTwYFgVFCUaE+j2MilucRB6IWX9gKMUqJM6wJxyYB0o1wlChGlYUSnwQw0l1EwoWMgBIY0F6kQQxHkEhAh4Zk/zq54SKpSlbqdvFXfz1q1ztnvec/ezz6nkt95373PrshMJElSOd7Q6AIkSdKWMbwlSSqM4S1JUmEMb0mSCmN4S5JUGMNbkqTCGN5SJyJiWUTMbnQd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Add9xxi7d14okn8rnPfY699trrde1XXHEFixYt4sILL9zidQKMHDmStWvXdqvv7NmzOe+882hubt7QtmjRIq666iouuOCCHm2/ERx5S5I2641vfCNLlizh/vvvZ6edduKiiy7q0Xp+8IMfbBLcW4Pm5uZ+D+7169f36fq6DO+IGBER90TE7yJiWUR8rWqfHBF3R8TDEXFtRGxTtW9bLa+oHp/UpxVLkhpm1qxZrFy5csPyueeey/7778++++7LWWedBcCLL77IYYcdxn777cc+++zDtddeC9RGve2Xwr788svZc889Oeigg7jrrrs2rO+4447juuuu27A8cuRIANauXcucOXOYPn06U6ZM4YYbbtiktlWrVnHggQcydepU9tlnH+64445u7dNtt93Ghz70IQBaWlo4/vjjmT17NrvtttvrQv3qq69mxowZTJ06lU996lMbAvnkk0+mubmZvffee8NrALVLf5999tm8+93v5ic/+Um3aumu7kyb/xl4T2aujYgm4M6I+CXwOeA7mXlNRPwTcAJwcXX7x8x8W0QcCXwL+HifVi1JGnDr169n4cKFnHDCCQDcfPPNPPzww9xzzz1kJocffji33347bW1t7LLLLtx0000APPfcc69bz6pVqzjrrLNYvHgxo0aN4uCDD2batGmb3faIESO4/vrr2WGHHXj66aeZOXMmhx9++OtO/PrRj37EIYccwplnnsn69et56aWXerSfDz74ILfeeisvvPACb3/72zn55JNZsWIF1157LXfddRdNTU18+tOfZv78+RxzzDGcc8457LTTTqxfv545c+awdOlS9t133w1133nnnT2qY3O6HHlnTfvBhKbqJ4H3AO0fj64EPlLdn1stUz0+JzxVUpKK9ac//YmpU6cyevRonnnmGd73vvcBtfC++eabmTZtGtOnT+fBBx/k4YcfZsqUKfzqV7/iS1/6EnfccQejRo163fruvvtuZs+ezdixY9lmm234+Me7Ht9lJmeccQb77rsv733ve1m5ciWrV69+XZ/999+fyy+/nJaWFu677z623377Hu3vYYcdxrbbbsuYMWMYN24cq1evZuHChSxevJj999+fqVOnsnDhQh555BEAFixYwPTp05k2bRrLli3jgQce2LCu7uxbT3TrmHdEDIuIJcBTwC3AfwD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9RGY5cCyzPz/EbX0x88YW1o+2ZE3B8RS6kdOhh0X6fYjAuB7YFbqq/K/VOjCxoIEfHRiGgFZgE3RcS/Nrqm/lSdlNh+qeblwIKt9FLNfS4ifgz8Gnh7RLRGxAmNrmkAHQAcDbyn+ve9JCI+2Oii+pKXR5UkqTCOvCVJKozhLUlSYQxvSZIKY3hLklQYw1uSpMIY3pIkFcbwliSpMP8fyA86rS7ZVMIAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x7fa194332630>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "#在训练集上观察预测残差的分布，看是否符合模型假设：噪声为0均值的高斯噪声\n",
    "f, ax = plt.subplots(figsize=(7, 5)) \n",
    "f.tight_layout() \n",
    "ax.hist(y_train - y_train_pred_lr,bins=40, label='Residuals Linear', color='b', alpha=.5); \n",
    "ax.set_title(\"Histogram of Residuals\") \n",
    "ax.legend(loc='best');"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 115,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The r2 score of RidgeCV on test is 0.7247284716181188\n",
      "The r2 score of RidgeCV on train is 0.8691651225112851\n",
      "alpha is: 264.30814869741084\n"
     ]
    }
   ],
   "source": [
    "#接下来试试岭回归\n",
    "from sklearn.linear_model import  RidgeCV\n",
    "#设置超参数（正则参数）范围\n",
    "n_alphas = 200\n",
    "# alphas count is 200, 都在10的-10次方和10的3次方之间\n",
    "alphas = np.logspace(-2, 3, n_alphas)\n",
    "\n",
    "#生成一个RidgeCV实例\n",
    "ridge = RidgeCV(alphas=alphas, store_cv_values=True)  \n",
    "\n",
    "#模型训练\n",
    "ridge.fit(X_train, y_train)    \n",
    "\n",
    "#预测\n",
    "y_test_pred_ridge = ridge.predict(X_test)\n",
    "y_train_pred_ridge = ridge.predict(X_train)\n",
    "\n",
    "\n",
    "# 评估，使用r2_score评价模型在测试集和训练集上的性能\n",
    "print( 'The r2 score of RidgeCV on test is', r2_score(y_test, y_test_pred_ridge))\n",
    "print( 'The r2 score of RidgeCV on train is', r2_score(y_train, y_train_pred_ridge))\n",
    "\n",
    "print ('alpha is:', ridge.alpha_)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
